home *** CD-ROM | disk | FTP | other *** search
- Path: softsite.co.at!wsog
- Date: 15 Feb 1996 16:00:00 +0100
- From: wsog@softsite.co.at (Walter Sommergruber)
- Newsgroups: comp.lang.c
- Message-ID: <62ttN_YbnTB@softsite.co.at>
- References: <4fthhh$7th@blackice.winternet.com>
- Subject: Re: Watch out! C "gotcha!"
- X-Newsreader: XP v3.02
- X-Charset: ISO-8859-1
- Organization: Sommergruber Software & Dienstleistungen
-
- Michael Schwarz (mschwarz@winternet.com) wrote on 14.02.96
- about "Watch out! C "gotcha!"":
-
- > switch (x)
- > {
- > case 1:
- > printf("It's 1.\n");
- > break;
- >
- > defalt:
- > printf("It's not 1.\n");
- > break;
- > }
- [snip]
- > My point is that several compilers we tried this on compiled thismistake
- > with no error or warning. If you, like so many of us, do not get enough
- > time to completely coverage test your code, this mistake can really bite
- > you on the behind. Your "default" code will never be executed!
-
- That's no mistake - it's valid C. "defalt:" is interpreted as a
- label for a potential goto. You write for instance:
- case 1:
- printf("abc");
- if( x ) goto defalt;
- printf("def");
- defalt:
- printf("something else");
-
- --- Take a look at ...
- Walter Sommergruber The Software Site
- email: wsog@softsite.co.at http://www.softsite.co.at/softsite/
-